package ai.people.netmon.warning.controller;

import ai.people.netmon.framework.domain.common.NameValueEntity;
import ai.people.netmon.framework.domain.common.TypeValueEntity;
import ai.people.netmon.framework.domain.warning.entity.WarningAnalysisModel;
import ai.people.netmon.framework.domain.warning.request.analysis.ModelListRequest;
import ai.people.netmon.framework.domain.warning.request.subject.SubjectModelRequest;
import ai.people.netmon.framework.domain.warning.vo.TrendAnalysisRespVO;
import ai.people.netmon.framework.domain.warning.vo.WarningAnalysisModelVO;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.warning.service.WarningAnalysisModelService;
import ai.people.netmon.warning.service.WarningSubjectAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 主题分析相关接口
 *
 * @author yuanqinglong
 * @date 2022/7/27 14:40
 */
@Validated
@RestController
@RequestMapping("/analysis/subject/")
public class SubjectAnalysisController {

    @Autowired
    private WarningAnalysisModelService warningAnalysisModelService;

    @Autowired
    private WarningSubjectAnalysisService warningSubjectAnalysisService;

    /**
     * 模型列表
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link WarningAnalysisModel}>
     */
    @PostMapping("/model-list")
    public Result<List<WarningAnalysisModelVO>> modelList(@RequestBody ModelListRequest reqParam){
        return ResultUtil.success(warningAnalysisModelService.subjectModelList(reqParam.getBusinessId()));
    }

    /**
     * 情感分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link NameValueEntity}<{@link String}, {@link String}>>>
     */
    @PostMapping("emotion-value")
    public Result<List<TypeValueEntity<String, Long>>> emotionAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success(warningSubjectAnalysisService.emotionAnalysis(reqParam));
    }

    /**
     * 源分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link NameValueEntity}<{@link String}, {@link String}>>>
     */
    @PostMapping("source-value")
    public Result<List<TypeValueEntity<String, Long>>> sourceAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success(warningSubjectAnalysisService.sourceAnalysis(reqParam));
    }

    /**
     * 趋势分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link TrendAnalysisRespVO}>>
     */
    @PostMapping("trend-value")
    public Result<List<TrendAnalysisRespVO>> trendAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success(warningSubjectAnalysisService.trendAnalysis(reqParam));
    }

    /**
     * 关键词分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link NameValueEntity}<{@link String}, {@link String}>>>
     */
    @PostMapping("keyword-value")
    public Result<List<NameValueEntity<String, Double>>> keywordAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success(warningSubjectAnalysisService.keywordAnalysis(reqParam));
    }

    /**
     * 标签分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link NameValueEntity}<{@link String}, {@link String}>>>
     */
    @PostMapping("tag-value")
    public Result<List<TrendAnalysisRespVO>> tagAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success(warningSubjectAnalysisService.tagAnalysis(reqParam));
    }

    /**
     * 论坛分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link NameValueEntity}<{@link String}, {@link String}>>>
     */
    @PostMapping("forum-value")
    public Result<List<NameValueEntity<String, String>>> forumAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success();
    }

    /**
     * 热门言论分析
     *
     * @param reqParam 要求参数
     * @return {@link Result}<{@link List}<{@link NameValueEntity}<{@link String}, {@link String}>>>
     */
    @PostMapping("hot-speech-value")
    public Result<List<NameValueEntity<String, String>>> hotSpeechAnalysis(@RequestBody SubjectModelRequest reqParam){
        return ResultUtil.success();
    }
}
